import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('asset.assetReturnResignation.fields');
const { t: common } = useI18n('common');
const assetReturnResignationFields = {
  number: t('number'),
  createTime: t('createTime'),
  user: t('user'),
  asset: t('asset'),
  department: t('department'),
  position: t('position'),
  description: t('description'),
  documentFileString: t('documentFileString'),
  returnTime: t('returnTime'),
  status: t('status'),
  operater: t('operater'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: assetReturnResignationFields.number,
    align: 'center',
    dataIndex: 'id',
  },
  // {
  //   title: assetReturnResignationFields.position,
  //   align: 'center',
  //   dataIndex: 'position_dictText',
  // },
  // {
  //   title: assetReturnResignationFields.returnTime,
  //   align: 'center',
  //   dataIndex: 'returnTime',
  //   customRender: ({ text }) => {
  //     return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
  //   },
  // },

  {
    title: assetReturnResignationFields.createTime,
    dataIndex: 'createTime',
  },
  {
    title: assetReturnResignationFields.description,
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: assetReturnResignationFields.status,
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'documentStatus', true, { '2': 'blue', '3': 'green', '4': 'red' });
    },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  // {
  //   label: assetReturnResignationFields.user,
  //   field: 'user',
  //   component: 'JSelectUserByDept',
  //   componentProps: {
  //     showButton: false,
  //   },
  // },
  {
    label: assetReturnResignationFields.status,
    field: 'status',
    component: 'JSelectMultiple',
    defaultValue: '1,2',
    componentProps: {
      dictCode: 'documentStatus',
      showChooseOption: false,
      multiple: true,
    },
  },

  {
    label: assetReturnResignationFields.createTime,
    field: 'createTime',
    component: 'RangePicker',
  },
  {
    label: assetReturnResignationFields.operater,
    field: 'updateBy',
    component: 'JSelectUserByDept',
    componentProps: {
      showButton: false,
    },
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: assetReturnResignationFields.user,
    field: 'user',
    component: 'JSelectUserByDept',
    componentProps: {
      labelKey: 'realname',
      maxSelectCount: 1,
    },
    dynamicRules: () => {
      return [{ required: true, message: `${common('chooseText')}${assetReturnResignationFields.user}!` }];
    },
  },
  {
    label: assetReturnResignationFields.description,
    field: 'description',
    component: 'Input',
    colProps: {
      span: 24,
    },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
